package cn.gyouzhe.entity;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 券实体
 *
 * @author wangchuan
 * @datetime 2018/2/12 22:00
 */
@Getter
@Setter
@NoArgsConstructor
@ToString
public class Coupon {
    private int id;
    /**
     * 商品ID
     */
    private String goodId;
    /**
     * 券ID
     */
    private String couponId;
    /**
     * 券价格
     */
    private BigDecimal price;
    /**
     * 券使用条件
     */
    private BigDecimal condition;
    /**
     * 券开始时间
     */
    private LocalDateTime startTime;
    /**
     * 券结束时间
     */
    private LocalDateTime endTime;

    private Coupon(String goodId, String couponId, BigDecimal price, BigDecimal condition, LocalDateTime startTime, LocalDateTime endTime) {
        this.goodId = goodId;
        this.couponId = couponId;
        this.price = price;
        this.condition = condition;
        this.startTime = startTime;
        this.endTime = endTime;
    }

    private Coupon(int id, String goodId, String couponId, BigDecimal price, BigDecimal condition, LocalDateTime startTime, LocalDateTime endTime) {
        this.id = id;
        this.goodId = goodId;
        this.couponId = couponId;
        this.price = price;
        this.condition = condition;
        this.startTime = startTime;
        this.endTime = endTime;
    }

    public static Coupon of(String goodId, String couponId, BigDecimal price, BigDecimal condition, LocalDateTime startTime, LocalDateTime endTime) {
        return new Coupon(goodId, couponId, price, condition, startTime, endTime);
    }

    public static Coupon of(int id, String goodId, String couponId, BigDecimal price, BigDecimal condition, LocalDateTime startTime, LocalDateTime endTime) {
        return new Coupon(id, goodId, couponId, price, condition, startTime, endTime);
    }
}
